interface ICreation {
  id: number;
  title: string;
  coverImage: string;
  createdAt: string;
}

interface IPageData {
  creations: ICreation[];
}

Page({
  data: {
    creations: []
  },

  onLoad() {
    this.loadCreations();
  },

  onPullDownRefresh() {
    this.loadCreations().then(() => {
      wx.stopPullDownRefresh();
    });
  },

  async loadCreations() {
    try {
      // 这里需要替换为实际的API调用
      const creations: ICreation[] = [
        {
          id: 1,
          title: '小红帽的故事',
          coverImage: '/assets/images/story1.png',
          createdAt: '2024-01-20'
        },
        {
          id: 2,
          title: '三只小猪',
          coverImage: '/assets/images/story2.png',
          createdAt: '2024-01-19'
        }
      ];
      
      this.setData({
        creations
      });
    } catch (error) {
      wx.showToast({
        title: '加载失败',
        icon: 'error'
      });
    }
  }
});